from resource_management import *
from jenkins import *

class jenkins_service(Script):

    def configure(self, env):
        import params
        env.set_params(params)
        jenkins_config()

    def install(self, env):
        # Install packages listed in metainfo.xml
        self.install_packages(env)
        self.configure(env)
        #if any other install steps were needed they can be added here



    #To stop the service, use the linux service stop command and pipe output to log file
    def stop(self, env):
        import params
        env.set_params(params)
        stop_cmd = format("systemctl  stop  jenkins")
        Execute(stop_cmd)

    #To start the service, use the linux service start command and pipe output to log file
    def start(self, env):
        import params
        env.set_params(params)
        new_jenkins_conf()
        start_cmd = format("systemctl start jenkins")
        Execute(start_cmd)

    #To get status of the, use the linux service status command
    def status(self, env):
        import status_params
        env.set_params(status_params)
        check_process_status(status_params.jenkins_pid_file)

if __name__ == "__main__":
    jenkins_service().execute()
